#ifndef CVIMG_TCP_H_
#define CVIMG_TCP_H_

#include <iostream>
#include <mutex>
#include <thread>
#include <time.h>
#include <ros/ros.h>
#include <std_msgs/Bool.h>
#include <std_msgs/Int8.h>
#include <std_msgs/Empty.h>
#include <geometry_msgs/Twist.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <tf/tf.h>
#include <tf/transform_listener.h>
#include <sensor_msgs/CameraInfo.h>
#include <sensor_msgs/Image.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

namespace cv_camera_capture
{

enum CameraNameSelect
{
    FRAME_CAMERA_SELECT = 0,
    BACK_CAMERA_SELECT = 1
};

class CameraCapture
{
public:
    void front_camera();
    void back_camera();
    CameraCapture();
    ~CameraCapture();

private:
    void run_subscribe();
    void get_param();
    void camera_state_msg(const std_msgs::Bool::ConstPtr &msg, int camera_select);
    void front_camera_msg(const std_msgs::Bool::ConstPtr &msg);

    ros::NodeHandle nh_front_camera_;
	ros::NodeHandle nh_back_camera_;
	
    ros::Subscriber sub_front_camera_;
    ros::Subscriber sub_back_camera_;

    std::mutex front_camera_mutex_;
    std::mutex back_camera_mutex_;

	bool front_camera_state_ = false;
	int front_camera_id_ = 0;
	int front_camera_rate_ = 30;
	int front_image_width_ = 1920;
	int front_image_height_ = 1080;
	std::string front_image_output_ = "/cv_camera/front_image";
	std::string get_front_camera_state_ = "/cv_camera/front_camera_state";

	bool back_camera_state_ = false;
	int back_camera_id_ = 1;
	int back_camera_rate_ = 30;
	int back_image_width_ = 1920;
	int back_image_height_ = 1080;
	std::string back_image_output_ = "/cv_camera/back_image";
	std::string get_back_camera_state_ = "/cv_camera/back_camera_state";
};

}

#endif
